<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <title>Title</title>
    </head>
    <body></body>
    <script>
        const p = new Promise((resolve, reject) => {
            throw "我错了";
        });

        p.catch(reason => {
            console.log("我在catch里面，", reason);
        });

        const p2 = new Promise((resolve, reject) => {
            setTimeout(() => {
                throw "我在回调里错了";
            }, 100);
        });

        p2.catch(reason => {
            console.log("我在回调后面，我不执行");
            console.log(reason);
        });

        const p3 = new Promise((resolve, reject) => {
            resolve();
            throw "我在resolve后面错了";
        });

        p3.catch(reason => {
            console.log("我在resolve后面，也不执行");
            console.log(reason);
        });

        const p4 = new Promise((resolve, reject) => {
            reject("我是reject");
            throw "我在reject后面错了";
        });

        p4.catch(reason => {
            console.log("我在reject后面，我执行，但是不捕获错误");
            console.log(reason);
        });

        const p5 = Promise.resolve();
        p5.catch(reason => {
            console.log("我是完成后的catch");
        }).then(
            result => {
                console.log("next promise's onFulfilled");
                console.log(result);
            },
            reason => {
                console.log("next promise's onRejected");
                console.log(reason);
            }
        );
    </script>
</html>
